package com.codeZ.FactoryPattern.simpleFactory.controller;

import com.codeZ.FactoryPattern.entity.AwardInfo;
import com.codeZ.FactoryPattern.entity.ResponseResult;
import com.codeZ.FactoryPattern.simpleFactory.factory.FreeGoodsFactory;
import com.codeZ.FactoryPattern.simpleFactory.service.IFreeGoods;

/**
 * 模拟发送接口
 *
 * @author codeZhang
 * @Date 2024/7/31 17:57
 */
public class DeliverController {
    public ResponseResult deliverGoods(AwardInfo awardInfo) {
        try {
            // 模拟调用接口
            IFreeGoods freeGoods = FreeGoodsFactory.getFreeGoods(awardInfo.getAwardTypes());
            ResponseResult responseResult = freeGoods.sendFreeGoods(awardInfo);
            System.out.println(responseResult.getStatus());
            return responseResult;
        }catch (Exception e){
            System.out.println(e.getLocalizedMessage());
            return new ResponseResult("500", "发送失败", "");
        }
    }
}
